package com.cssy.xxkj.logic.service.impl;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.cssy.authority.service.IScUserRolewhPlaceService;
import com.cssy.xxkj.basic.entity.BasicStorageInfoTestDO;
import com.cssy.xxkj.basic.entity.BasicStorageInfoTypeTestDO;
import com.cssy.xxkj.basic.service.IBasicStorageInfoTestService;
import com.cssy.xxkj.basic.service.IBasicStorageInfoTypeTestService;
import com.cssy.xxkj.logic.contants.BillTypeConstant;
import com.cssy.xxkj.logic.entity.LogicProductionStorageinDO;
import com.cssy.xxkj.logic.entity.LogicProductionStorageoutDO;
import com.cssy.xxkj.logic.entity.LogicPurchaseWareDO;
import com.cssy.xxkj.logic.entity.LogicPurchaseWareItemDO;
import com.cssy.xxkj.logic.entity.LogicWarehouseDetailsDO;
import com.cssy.xxkj.logic.entity.LogicWarehouseMaterialoutDO;
import com.cssy.xxkj.logic.entity.LogicWarehouseOtherinDO;
import com.cssy.xxkj.logic.entity.LogicWarehouseOtherinItemDO;
import com.cssy.xxkj.logic.entity.LogicWarehouseOtheroutDO;
import com.cssy.xxkj.logic.service.ILogicProductionStorageInService;
import com.cssy.xxkj.logic.service.ILogicProductionStorageOutService;
import com.cssy.xxkj.logic.service.ILogicPurchaseWareItemService;
import com.cssy.xxkj.logic.service.ILogicPurchaseWareService;
import com.cssy.xxkj.logic.service.ILogicWareHouseOtherInItemService;
import com.cssy.xxkj.logic.service.ILogicWareHouseOtherInService;
import com.cssy.xxkj.logic.service.ILogicWareHouseOtherOutService;
import com.cssy.xxkj.logic.service.ILogicWarehouseDetailsService;
import com.cssy.xxkj.logic.service.IMaterialOutService;
import com.cssy.xxkj.logic.service.IReportsService;
import com.cssy.yd.logic.util.SqlUtil;
import com.plat.helper.JqGridHandler;
import com.plat.helper.SearchCondition;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
@Service("reportsService")
public class ReportsServiceImpl implements IReportsService {
	@Resource(name="scUserRolePlaceService")
	private IScUserRolewhPlaceService scUserRolePlaceService;
	
	@Resource(name="logicWarehouseDetailsService")
	private ILogicWarehouseDetailsService logicWarehouseDetailsService;
	
	@Resource(name="logicWareHouseOtherInService")//其他入库
	private ILogicWareHouseOtherInService logicWareHouseOtherInService;
	
	@Resource(name="logicWareHouseOtherInItemService")
	private ILogicWareHouseOtherInItemService logicWareHouseOtherInItemService;
	
	@Resource(name="logicWareHouseOtherOutService")//其他出库
	private ILogicWareHouseOtherOutService logicWareHouseOtherOutService;
	
	@Resource(name="logicProductionStorageInService")//成品入库
	private ILogicProductionStorageInService logicProductionStorageInService;
	
	@Resource(name="logicProductionStorageOutService")//成品出库
	private ILogicProductionStorageOutService logicProductionStorageOutService;
	
	//采购入库
	@Resource(name="logicPurchaseWareService")
	private ILogicPurchaseWareService logicPurchaseWareService;
	
	@Resource(name="logicPurchaseWareItemService")
	private ILogicPurchaseWareItemService logicPurchaseWareItemService;
	
	@Resource(name="materialOutServiceImpl")
	private IMaterialOutService materialOutService;
	
	//仓库Service
	@Resource(name = "basicStorageInfoTypeTestService")
	private IBasicStorageInfoTypeTestService basicStorageInfoTypeTestService;
	
	//仓库管理Service
	@Resource(name = "basicStorageInfoTestService")
	private IBasicStorageInfoTestService basicStorageInfoTestService;
	
	@Override
	public List<LogicWarehouseDetailsDO> finListByConditions(
			HttpServletRequest request) {
		String type=request.getParameter("type");
		SearchConditions scsNew = this.getCondition(request);
		SearchResult result= logicWarehouseDetailsService.findListByExample(scsNew);
		List<LogicWarehouseDetailsDO> ld=result.getResults();
		SearchConditions scsClean = new SearchConditions();
		//查询所有的其他入库单
		List<LogicWarehouseOtherinDO> otherInList=logicWareHouseOtherInService.findListByExample(scsClean).getResults();
		Map<String, LogicWarehouseOtherinDO> otherInMapItem=this.getOtherIn(otherInList,"1"); //id
		Map<String, LogicWarehouseOtherinDO> otherInMap = this.getOtherIn(otherInList,"0");// Zd001InCode
		Map<String, LogicWarehouseOtherinItemDO> otherInItemMap = this.getOtherInItemMap(scsClean, otherInMapItem);//item
		//其他出库
		Map<String, LogicWarehouseOtheroutDO> otherOutMap = this.getWarehouseOtherout(scsClean);
		//采购入库
		List<LogicPurchaseWareDO> purchaseList=logicPurchaseWareService.findListByExample(scsClean).getResults();
		Map<String, LogicPurchaseWareDO> purchaseMap= this.getPurchaseWare(purchaseList,"0");//key zd003code
		Map<String, LogicPurchaseWareDO> purMap = this.getPurchaseWare(purchaseList,"1");//key id
		Map<String, LogicPurchaseWareItemDO> purItemMap = this.getPurItemMap(scsClean, purMap);//采购入库
		//成品入库
		List<LogicProductionStorageinDO> proStorageInList= logicProductionStorageInService.findListByExample(scsClean).getResults();
		Map<String, LogicProductionStorageinDO> proStorageInMap=this.getProStorageInMap(proStorageInList);
		//成品出库
		List<LogicProductionStorageoutDO> proStorageOutList=logicProductionStorageOutService.findListByExample(scsClean).getResults();
		Map<String, LogicProductionStorageoutDO> proStorageOUtMap=this.getProStorageOutMap(proStorageOutList);
		//领料出库
		List<LogicWarehouseMaterialoutDO> materialOutList=materialOutService.findListByExample(scsClean).getResults();
		Map<String, LogicWarehouseMaterialoutDO> marerialOutMap= new HashMap<String, LogicWarehouseMaterialoutDO>();
		for(LogicWarehouseMaterialoutDO lmd:materialOutList){
			marerialOutMap.put(lmd.getZd001MaterialCode(), lmd);
		}
		Map<String, Boolean> isProSto = isProdctStorage(scsClean);//判断仓库类型 成品仓 true
		List<LogicWarehouseDetailsDO> lds= new ArrayList<LogicWarehouseDetailsDO>();//成品
		List<LogicWarehouseDetailsDO> ldsc= new ArrayList<LogicWarehouseDetailsDO>();//成品
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy年MM月dd日");
		for(LogicWarehouseDetailsDO lwd:ld){
			if(isProSto.get(lwd.getZd003WhName())){//成品
				if(!type.equals("0")){//0表示成品
					continue;
				}
				lds.add(getNewLogicWarehouseDetailsDO(sdf,otherInMap, otherOutMap,purchaseMap, marerialOutMap,purItemMap ,otherInItemMap,lwd,proStorageInMap,proStorageOUtMap,true));
			}else{
				if(!type.equals("1")){
					continue;
				}
				ldsc.add(getNewLogicWarehouseDetailsDO(sdf,otherInMap, otherOutMap,purchaseMap, marerialOutMap, purItemMap,otherInItemMap,lwd,proStorageInMap,proStorageOUtMap,false));
			}
			
		}
		if(type.equals("0")){//判断导出类型
			return lds;
		}else{
			return ldsc;
		}
	}
	private Map<String, Boolean> isProdctStorage(SearchConditions scsClean) {
		//仓库类型
		List<BasicStorageInfoTypeTestDO> storageTypeList=basicStorageInfoTypeTestService.findListByExample(scsClean).getResults();
		Map<String, String> storageTypeMap=new HashMap<String, String>();
		for(BasicStorageInfoTypeTestDO bd:storageTypeList){
			storageTypeMap.put(bd.getId(), bd.getZd001Code());//为成品时  value=成品
		}
		//获得仓库的map
		Map<String , Boolean> isProSto= new HashMap<String, Boolean>();
		List<BasicStorageInfoTestDO> whList=basicStorageInfoTestService.findListByExample(scsClean).getResults();
		for(BasicStorageInfoTestDO wh:whList){
			String stm=storageTypeMap.get(wh.getZd001WhTypeId());
			if(StringUtils.isNotEmpty(stm)&&stm.equals("WHLX1411170001")){
				isProSto.put(wh.getZd003Name(), true);
			}else{
				isProSto.put(wh.getZd003Name(), false);
			}
		}
		return isProSto;
	}
	private Map<String, LogicPurchaseWareItemDO> getPurItemMap(
			SearchConditions scsClean, Map<String, LogicPurchaseWareDO> purMap) {
		List<LogicPurchaseWareItemDO> purItemList= logicPurchaseWareItemService.findListByExample(scsClean).getResults();
		Map<String, LogicPurchaseWareItemDO> purItemMap=new HashMap<String, LogicPurchaseWareItemDO>();
		for(LogicPurchaseWareItemDO li:purItemList){//单号  物品编码 名称  型号 规格 颜色 材质
			LogicPurchaseWareDO purchaseWare=purMap.get(li.getZd001PusWareId());
			if(purchaseWare==null){
				continue;
			}
			if(StringUtils.isEmpty(purchaseWare.getZd003Code())){
				purchaseWare.setZd003Code(null);
			}
			if(StringUtils.isEmpty(li.getZd004Code())){
				li.setZd004Code(null);
			}
			if(StringUtils.isEmpty(li.getZd005Name())){
				li.setZd005Name(null);;
			}
			if(StringUtils.isEmpty(li.getZd011Size())){
				li.setZd011Size(null);
			}
			if(StringUtils.isEmpty(li.getZd007Model())){
				li.setZd007Model(null);
			}
			if(StringUtils.isEmpty(li.getZd009Color())){
				li.setZd009Color(null);
			}
			if(StringUtils.isEmpty(li.getZd010Quality())){
				li.setZd010Quality(null);
			}
			String key=purchaseWare.getZd003Code()+"_"+li.getZd004Code()
					+"_"+li.getZd005Name()+"_"+li.getZd007Model()+"_"+li.getZd011Size()+"_"+
					li.getZd009Color()+"_"+li.getZd010Quality();
			purItemMap.put(key, li);
		}
		return purItemMap;
	}
	private Map<String, LogicWarehouseOtherinItemDO> getOtherInItemMap(
			SearchConditions scsClean,
			Map<String, LogicWarehouseOtherinDO> otherInMapItem) {
		List<LogicWarehouseOtherinItemDO> otherInItemList=logicWareHouseOtherInItemService.findListByExample(scsClean).getResults();
		Map<String, LogicWarehouseOtherinItemDO> otherInItemMap= new HashMap<String, LogicWarehouseOtherinItemDO>();
		for(LogicWarehouseOtherinItemDO loi:otherInItemList){
			//单号  物品编码 名称  型号 规格 颜色 材质
			LogicWarehouseOtherinDO otherItem=otherInMapItem.get(loi.getZd001OtherInId());
			if( otherItem==null){
				continue;
			}
			if(StringUtils.isEmpty(otherItem.getZd001InCode())){
				otherItem.setZd001InCode(null); 
			}
			if(StringUtils.isEmpty(loi.getZd002MaterialsCode())){
				loi.setZd002MaterialsCode(null) ;
			}
			if(StringUtils.isEmpty(loi.getZd002MaterialsName())){
				loi.setZd002MaterialsName(null)  ;
			}
			if(StringUtils.isEmpty(loi.getZd004MaterialsModel())){
				loi.setZd004MaterialsModel( null) ;
			}
			if(StringUtils.isEmpty(loi.getZd003MaterialsSpec())){
				loi.setZd003MaterialsSpec(null) ;
			}
			if(StringUtils.isEmpty(loi.getZd005MaterialsColor())){
				loi.setZd005MaterialsColor(null) ;
			}
			if(StringUtils.isEmpty(loi.getZd005MaterialsQuanlity())){
				loi.setZd005MaterialsQuanlity(null) ;
			}
			String key= otherItem.getZd001InCode()+"_"+loi.getZd002MaterialsCode()+"_"+
			loi.getZd002MaterialsName()+"_"+loi.getZd004MaterialsModel()+"_"+loi.getZd003MaterialsSpec()+"_"+
					loi.getZd005MaterialsColor()+"_"+loi.getZd005MaterialsQuanlity();
			otherInItemMap.put(key, loi);
		}
		return otherInItemMap;
	}
	
	private Map<String, LogicProductionStorageinDO> getProStorageInMap(List<LogicProductionStorageinDO> proStorageInList){
		Map<String, LogicProductionStorageinDO> proStorageInMap= new HashMap<String , LogicProductionStorageinDO>();
		for(LogicProductionStorageinDO li:proStorageInList){
			proStorageInMap.put(li.getZd001InCode(), li);
		}
		return proStorageInMap;
	}
	
	private Map<String, LogicProductionStorageoutDO> getProStorageOutMap(List<LogicProductionStorageoutDO> proStorageOutList){
		Map<String, LogicProductionStorageoutDO> proStorageOutMap= new HashMap<String, LogicProductionStorageoutDO>();
		for(LogicProductionStorageoutDO ls:proStorageOutList){
			proStorageOutMap.put(ls.getZd001OutCode(), ls);
		}
		return proStorageOutMap;
	}
	
	private Map<String, LogicWarehouseOtherinDO> getOtherIn(
			List<LogicWarehouseOtherinDO> otherInList , String type) {
		Map<String, LogicWarehouseOtherinDO> otherInMap= new HashMap<String, LogicWarehouseOtherinDO>();
		for(LogicWarehouseOtherinDO oi:otherInList){
			if(type.equals("0")){
				otherInMap.put(oi.getZd001InCode(), oi);
			}else if(type.equals("1")){
				otherInMap.put(oi.getId(), oi);
			}
		}
		return otherInMap;
	}
	private Map<String, LogicPurchaseWareDO> getPurchaseWare(
			List<LogicPurchaseWareDO> purchaseList,String type) {
		Map<String, LogicPurchaseWareDO> purMap=new HashMap<String, LogicPurchaseWareDO>();
		for(LogicPurchaseWareDO lsd:purchaseList){
			if(type.equals("1")){
				purMap.put(lsd.getId(), lsd);
			}else if( type.equals("0")){
				purMap.put(lsd.getZd003Code(), lsd);
			}
		}
		return purMap;
	}
	private Map<String, LogicWarehouseOtheroutDO> getWarehouseOtherout(
			SearchConditions scsClean) {
		//其他出库 
		List<LogicWarehouseOtheroutDO> otherOutList= logicWareHouseOtherOutService.findListByExample(scsClean).getResults();
		Map<String, LogicWarehouseOtheroutDO> otherOutMap= new HashMap<String, LogicWarehouseOtheroutDO>();
		for(LogicWarehouseOtheroutDO psd:otherOutList){
			otherOutMap.put(psd.getZd001OutCode(), psd);
		}
		return otherOutMap;
	}
	private LogicWarehouseDetailsDO getNewLogicWarehouseDetailsDO(
			SimpleDateFormat sdf,
			Map<String, LogicWarehouseOtherinDO> otherInMap,
			Map<String, LogicWarehouseOtheroutDO> otherOutMap,
			Map<String, LogicPurchaseWareDO> purchaseMap,
			Map<String, LogicWarehouseMaterialoutDO> marerialOutMap,
			Map<String, LogicPurchaseWareItemDO> purItemMap,
			Map<String, LogicWarehouseOtherinItemDO> otherInItemMap,
			LogicWarehouseDetailsDO lwd,
			Map<String, LogicProductionStorageinDO> proStorageInMap,
			Map<String, LogicProductionStorageoutDO> proStorageOutMap,
			boolean isPur) {
		if(lwd.getZd013Price()==null){
			lwd.setZd013Price(BigDecimal.ZERO);//现单价 归零
		}
		if(StringUtils.isEmpty(lwd.getZd001BillCode())){
			lwd.setZd001BillCode(null);
		}
		if(StringUtils.isEmpty(lwd.getZd005MaterialsCode())){
			lwd.setZd005MaterialsCode(null);
		}
		if(StringUtils.isEmpty(lwd.getZd005MaterialsName())){
			lwd.setZd005MaterialsName(null);
		}
		if(StringUtils.isEmpty(lwd.getZd006MaterialsSpec())){
			lwd.setZd006MaterialsSpec(null);
		}
		if(StringUtils.isEmpty(lwd.getZd007MaterialsModel())){
			lwd.setZd007MaterialsModel(null);
		}
		if(StringUtils.isEmpty(lwd.getZd008MaterialsColor())){
			lwd.setZd008MaterialsColor(null);
		}
		if(StringUtils.isEmpty(lwd.getZd008MaterialsQuanlity())){
			lwd.setZd008MaterialsQuanlity(null);
		}
		String key =lwd.getZd001BillCode()+"_"+lwd.getZd005MaterialsCode() //单号  物品编码 名称  型号 规格 颜色 材质
				+"_"+lwd.getZd005MaterialsName()+"_"+lwd.getZd007MaterialsModel()
				+"_"+lwd.getZd006MaterialsSpec()+"_"+lwd.getZd008MaterialsColor()
				+"_"+lwd.getZd008MaterialsQuanlity();
		if(lwd.getZd002BillType().equals(BillTypeConstant.PURCHASEWARE)){//没有入成品仓 带供应商 流水号
			lwd.setZd002BillType("采购入库");
			LogicPurchaseWareDO pruchaseWare= purchaseMap.get(lwd.getZd001BillCode());
			if(pruchaseWare!=null){
				lwd.setZd004WhPositionCode(pruchaseWare.getZd017MaterialInCode());//送货单号
				lwd.setZd016Remark(sdf.format(pruchaseWare.getZd013Date()));//做单日期
				lwd.setZd020PiCode(pruchaseWare.getZd016PiCode());//单据的PI号
				if(isPur){
					lwd.setZd003WhId(pruchaseWare.getZd008SupeName());//供应商
					lwd.setZd022ConsumerName(pruchaseWare.getZd019AccountName());//客户
				}else{
					lwd.setZd022ConsumerName(pruchaseWare.getZd008SupeName());//供应商
				}
			}
			LogicPurchaseWareItemDO item= purItemMap.get(key);
			if(item!=null){
				lwd.setZd013Price(item.getZd016Price());
			} 
			lwd.setZd004WhPositionName(null);//零时作为业务员的
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.PURCHASERETURN)){
			lwd.setZd002BillType("采购退货");
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.ALLOCATION)){
			lwd.setZd002BillType("调拨");
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.OTHEROUTWH)){
			lwd.setZd002BillType("其他出库");
			LogicWarehouseOtheroutDO otherOut=otherOutMap.get(lwd.getZd001BillCode());
			if(otherOut!=null){
				lwd.setZd004WhPositionCode(otherOut.getZd013RunningNumber());//领料流水号
				lwd.setZd020PiCode(otherOut.getZd012PiCode());
				lwd.setZd016Remark(sdf.format(otherOut.getZd010OtherDate()));//制单日期
				if(isPur){//成品 仓 时 会有业务员
					String[] arr=otherOut.getZd011CustomerName().split("-");
					lwd.setZd004WhPositionName(arr[arr.length-1]);//零时作为业务员的
					lwd.setZd022ConsumerName(otherOut.getZd011CustomerName());//客户
				}else{
					lwd.setZd022ConsumerName(null);//供应商
					lwd.setZd004WhPositionName(null);//零时作为业务员的
				}
			}
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.OTHERINWH)){
			lwd.setZd002BillType("其他入库");
			LogicWarehouseOtherinDO otherIn=otherInMap.get(lwd.getZd001BillCode());
			if(otherIn!=null){//成品仓时 会有业务原
				lwd.setZd004WhPositionCode(otherIn.getZd012MaterialInCode());
				lwd.setZd016Remark(sdf.format(otherIn.getZd010OtherDate()));//制单日期
				lwd.setZd020PiCode(otherIn.getZd005PiCode());
				if(isPur){
					String[] arr=otherIn.getZd013AccountName().split("-");
					lwd.setZd004WhPositionName(arr[arr.length-1]);//零时作为业务员的
					lwd.setZd022ConsumerName(otherIn.getZd013AccountName());//客户
					lwd.setZd004WhPositionId(otherIn.getZd011CustomerName());//作为供应商
				}else{
					lwd.setZd022ConsumerCode(otherIn.getZd011CustomerName());
				}
			}
			LogicWarehouseOtherinItemDO otherInItem=otherInItemMap.get(key);
			if(otherInItem!=null){
				lwd.setZd013Price(otherInItem.getZd009Price());
			}
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.PROIN)){
			lwd.setZd002BillType("成品入库");
			LogicProductionStorageinDO productionStorageIn=proStorageInMap.get(lwd.getZd001BillCode());
			if(productionStorageIn!=null){
				lwd.setZd016Remark(sdf.format(productionStorageIn.getZd010OtherDate()));//制单日期
				lwd.setZd020PiCode(productionStorageIn.getZd003PiCode());
				lwd.setZd004WhPositionName(productionStorageIn.getZd015SalesMan());//零时作为业务员
				lwd.setZd022ConsumerName(productionStorageIn.getZd012CustomerName());//客户
			}
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.PROOUT)){
			lwd.setZd002BillType("成品出库");
			LogicProductionStorageoutDO proStorageOut=proStorageOutMap.get(lwd.getZd001BillCode());
			if(proStorageOut != null){
				lwd.setZd016Remark(sdf.format(proStorageOut.getZd010OtherDate()));//制单日期
				lwd.setZd020PiCode(proStorageOut.getZd003PiCode());
				lwd.setZd004WhPositionName(proStorageOut.getZd015SalesMan());
				lwd.setZd022ConsumerName(proStorageOut.getZd012CustomerName());//客户
			}
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.MATERIALOUT)){//材料
			lwd.setZd002BillType("生产领料出库");
			LogicWarehouseMaterialoutDO marerialOut=marerialOutMap.get(lwd.getZd001BillCode());
			if(marerialOut!=null){
				lwd.setZd004WhPositionCode(marerialOut.getZd012RunningNumber());
				lwd.setZd016Remark(sdf.format(marerialOut.getZd010OtherDate()));
				lwd.setZd020PiCode(marerialOut.getZd004PICode());
			}
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.PRORETURN)){
			lwd.setZd002BillType("生产退料");
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.CHECKBACK)){
			lwd.setZd002BillType("反审");
			
		}else if(lwd.getZd002BillType().equals(BillTypeConstant.CHECKTASK)){
			lwd.setZd002BillType("盘点");
			
		}
		if(lwd.getZd011BasicQuantity().compareTo(BigDecimal.ZERO)>-1){//把Zd010Quantity为出库数量
			lwd.setZd010Quantity(BigDecimal.ZERO);
		}else{
			lwd.setZd010Quantity(lwd.getZd011BasicQuantity().abs());
			lwd.setZd011BasicQuantity(BigDecimal.ZERO);
		}
		return lwd;
	}
	
	private  SearchConditions getCondition(HttpServletRequest request) {
		JqGridHandler hander = new JqGridHandler(request);
		SearchConditions scs= new SearchConditions();
		hander.getWheres(scs);
		try {
			hander.setFilters(new String(request.getParameter("filters").getBytes(
					"ISO-8859-1"), "UTF-8"));
		} catch (Exception e) {
			e.printStackTrace();
		}
		scs.clearCondition();
		hander.getWheres(scs);
		Map<String,Object> sqlWHMap = SqlUtil.sqlUtil.roleWhSqlFilter(request, scUserRolePlaceService,"zd003WhCode");
		scs.addCondition(sqlWHMap.get("option")+"",(List<String>)sqlWHMap.get("roleWhList"));
		scs.setLimitClause(null);
		if(StringUtils.isEmpty(scs.getOrderBy())){
			scs.setOrderBy("bizCreatorDate desc");
		}
		return scs;
	}



}
